package com.techsen.tsweb.sys.web.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.techsen.tsweb.core.util.TreeUtil;
import com.techsen.tsweb.sys.security.ResourceNode;
import com.techsen.tsweb.sys.service.MenuService;
import com.techsen.tsweb.sys.service.OperService;
import com.techsen.tsweb.sys.service.ResourceService;

@Controller
@RequestMapping("/sys/resource")
public class ResourceController {

    @javax.annotation.Resource
    private ResourceService resourceService;
    
    @javax.annotation.Resource
    private MenuService menuService;
    
    @javax.annotation.Resource
    private OperService operService;
    
    /**
     * 查找所有资源
     */
    @RequestMapping("/list")
    public @ResponseBody List<ResourceNode> list(boolean tree) {
        List<ResourceNode> list = ResourceNode.convert(this.resourceService.findAll());
        if (tree) {
            list = TreeUtil.toTree(list);
        }
        return list;
    }
    
}
